14 #define MAX(a,b) ((a>b)?(a):(b))
20 int lcs(const string
&s
, const string
&t
){
21 int m
= s
.size(), n
= t
.size();
22 if (m
== 0 || n
== 0) return 0;
23 for (int i
=0; i
<=m
; ++i
)
25 for (int j
=1; j
<=n
; ++j
)
27 for (int i
=0; i
<m
; ++i
)
28 for (int j
=0; j
<n
; ++j
)
30 dp
[i
+1][j
+1] = dp
[i
][j
]+1;
32 dp
[i
+1][j
+1] = MAX(dp
[i
+1][j
], dp
[i
][j
+1]);
45 cout
<< "Case #"<< caso
<<": you can visit at most " << lcs(s
, t
) << " cities." << endl
;